# Contributor: Díaz Urbaneja Diego <sodomon2@gmail.com>
# Maintainer: Díaz Urbaneja Diego <sodomon2@gmail.com>
pkgname=dhewm3
pkgver=1.5.1
pkgrel=0
pkgdesc="Doom 3 engine with native 64-bit support, SDL, and OpenAL"
url="https://dhewm3.org/"
arch="x86_64 x86" # disabled for the other architectures due to compiling problems
license="GPL-3.0-only"
depends="curl libogg libpng libvorbis"
makedepends="cmake libjpeg-turbo-dev libogg-dev libpng-dev libvorbis-dev make
	openal-soft-dev sdl2-dev zlib-dev"
options="!check" # make check not implemented
source="$pkgname-$pkgver.tar.gz::https://github.com/dhewm/dhewm3/archive/$pkgver.tar.gz
	dhewm3.desktop
	dhewm3.png"
builddir="$srcdir/$pkgname-$pkgver/neo"

build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	cmake -B build \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DBUILD_SHARED_LIBS=True \
		-DCMAKE_BUILD_TYPE=None \
		-DD3XP=1 \
		-DDEDICATED=1 \
		$CMAKE_CROSSOPTS .
	cmake --build build
}

package() {
	DESTDIR="$pkgdir" cmake --install build
	install -Dm644 "$srcdir"/dhewm3.desktop "$pkgdir/usr/share/applications/dhewm3.desktop"
	install -Dm644 "$srcdir"/dhewm3.png "$pkgdir/usr/share/pixmaps/dhewm3.png"
}

sha512sums="b485cadea173e8cf36c04b01ccc8e2e1ab1354b174fd11c967e7e361b084bd96fd781494b7c416097d39ea2e15e69ad948c6600f16f711526a17c9546243a0fa  dhewm3-1.5.1.tar.gz
377d34c4d9ab21b09a501431e1bf8d123d3655a47499a7664db85168e2f85b73c8792bc958026593299eac57449f813b10047beb302784cc53d096e1cc37efbd  dhewm3.desktop
13f7a50d1f57d35bf582c3d99ff4dea4b18e60827f62aa640b7b43d419a3f4f478b45311d2abacfd2aa2f033c59f5c6253aa4916fc234b41eb6cc70d5eeac17c  dhewm3.png"
